var paymentCtrl  = new XFApp.client();

XFApp.client.prototype.payment = {
		successCode : 10000,	
		urlItems : {
			initListURL: basePath+"/recharge/init",
			submitURL: basePath+"/recharge/submit",
		},	
		
		event : function (){			
			_this = this;
			
			$("#submitBtn").on("click",function(){
				
				if(!$("#amount").val()){
					$("#amount-error").html('请填写充值金额');
				}
				
				if(!$("#amount-error").text()){
					paymentCtrl.payment.submit();
				}
			});
			
			//表单验证
			//_this.formValidate();
			
			//$("#amount").on("keypress",function(){
			//	_this.inputValidator($(this));
			//});
			
			$("#amount").on("blur",function(){
				_this.moneyCheck($("#amount"));
			})
		},	
		
		formValidate : function(){
			$("#inputForm").validate({				
		         rules: {
		        	amount: {
		        				required :true,
		        				amountCheck:true		        		
		        			}
				 },
				 messages: {
					amount: {
								required : "请填写充值金额",
								amountCheck:"金额格式不正确"
							}
				 }
		    });
			$("#inputForm").validate();
		},
		
		moneyCheck : function (obj){
			var result = moneyCtrl.money.check_HighFloatF(obj,'amount-error','充值金额','hiddamount');
			if(result){
				$("#amount-error").html("");
			}
		},
		
		inputValidator: function(obj){
			return moneyCtrl.money.onKeyDownVali(obj);
		},
		
		submit : function (){			
			
			   var entity = {
			        userId : $("#hiddenId").val(),
			        amount : $("#hiddamount").val()	,
			        transactionType : 5 ,//交易类型  1, "报关/报检" 2, "运费" 3, "仓储费" 4, "提现" 5, "充值" 6, "支付"  	
			        paymentType : 1 , //消费类型 1, "银行卡"  2, "支付宝" 3, "财付通"  4, "微信支付"  5, "支付宝余额"  6, "优惠券"
			        platformNo : 2 ,  //用户业务平台 1 后台管理员 2俄信通					
				}
		    	
		    	$.ajax({
		    		url :_this.urlItems.submitURL,
		    		data : entity,
		    		dataType : "json",
		    		type : 'post',
		    		success : function(data) {				
		    			if(data.code==_this.successCode){		    				
		    				webAlert({
				                title:'提示',
				                content: data.msg,
				                opacity:.5,
				                bg:"gray",
				                width:300,
				                height:10,
				                button:[
				                        {
				                        name:"确定",
				                        callback:function(){
				                        	window.location = basePath+"/recharge/index" ;
				                        	this.close();
				                        }
				                        }]
				            });
		    			}else{
		    				window.webDialogUtil.alert("提示",data.msg);
		    			}
		    		}
		    	});
		},
		
		
},

$(function(){	
	
	paymentCtrl.payment.event();
	
});